'use strict';
const db = uniCloud.database()
const coll = db.collection('user')
exports.main = async (event, context) => {
	//event为客户端上传的参数
	console.log('event : ', event)
	let res1 = await coll.where({
		openid:event.openid
	}).get()
	console.log(res1)
	if (res1.data.length>0) {
		return res1
	} else{
		let res = await coll.add({
		nickname:event.nickname,
		city:event.city,
		country:event.country,
		openid:event.openid,
		headimgurl:event.headimgurl,
		sex:event.sex,
		province:event.province,
		status:0,
		num:0,
		flag:'flag'
	})
	//返回数据给客户端
	return res
	}
	
	
};
